<?php

namespace App\Providers;

use App\Models\AcceptRecord;
use App\Models\Company;
use App\Models\Group;
use App\Models\Project;
use App\Models\Admin;
use App\Models\WxClient;
use App\Policies\ApiPolicy;
use App\Policies\CompanyPolicy;
use App\Policies\GroupPolicy;
use App\Policies\MenuPolicy;
use App\Policies\ProjectPolicy;
use App\Policies\UserPolicy;
use App\Policies\WxClientPolicy;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Menu' => MenuPolicy::class,

        Company::class => CompanyPolicy::class,

        User::class => UserPolicy::class,

        Group::class => GroupPolicy::class,

        WxClient::class => WxClientPolicy::class,

        Project::class => ProjectPolicy::class,

        AcceptRecord::class => ApiPolicy::class,
    ];

    /**
     * Register any application authentication / authorization services.
     *
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
     * @return void
     */
    public function boot(GateContract $gate)
    {
        $this->registerPolicies($gate);

        // 决定是否可以显示管理功能菜单
        $gate->define('show-admin-menu', 'App\\Services\\AdminService@canShowAdminMenu');
    }
}
